<%@ taglib prefix="page" uri="http://com.qipay/pagelib" %>
<%@ page language="java" import="com.qipay.admin.utils.SiteHelper"
         contentType="text/html;charset=utf-8" %>
<%@ page import="org.apache.commons.collections.CollectionUtils" %>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="java.util.List" %>
<%@ page import="com.qipay.baas.model.ChannelType" %>
<!doctype html>
<html>
<head>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <jsp:include page="head.jsp"></jsp:include>
    <link rel="stylesheet" href="<%= request.getAttribute("StaticHost") %>/css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" href="<%= request.getAttribute("StaticHost") %>/css/bootstrap-datepicker3.min.css">
    <link rel="stylesheet" href="<%= request.getAttribute("StaticHost") %>/css/list.css">
    <title>SP费率报表</title>
    <script type="text/javascript">
        document.getElementsByTagName("html")[0].style.fontSize=screen.availWidth/200+"px";
    </script>

</head>
</head>
<body class="devpreview hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <jsp:include page="nav.jsp"></jsp:include>
    <jsp:include page="left.jsp"></jsp:include>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-md-12">
                    <div class="box border" >

                        <!-- /.box-header -->
                        <div>
                            <%
                                String from = (String) request.getAttribute("from");
                                String to = (String) request.getAttribute("to");
                                Long spId = (Long) request.getAttribute("spId");
                                String spName = (String) request.getAttribute("spName");
                                String service = (String) request.getAttribute("service");
                                Integer channel = (Integer) request.getAttribute("channel");

                                Double amount = (Double) request.getAttribute("amount");
                                Double spFee = (Double) request.getAttribute("spFee");
                                Double left = (Double) request.getAttribute("left");
                            %>
                                <form id="searchForm" class="" action="${pageContext.request.contextPath}/statement/sp">
                                    <div class="new-group date form_datetime">
                                        <label for="from">开始日期：</label>
                                        <input type="text" class="" id="from" name="from" readonly
                                               value="<%= StringUtils.isNotBlank(from) ?from:""%>">
                                    </div>
                                    <div class="new-group date form_datetime">
                                        <label for="to">结束日期：</label>
                                        <input type="text" class="" id="to" name="to" readonly
                                               value="<%= StringUtils.isNotBlank(to) ?to:""%>">
                                    </div>
                                    <div class="new-group date form_datetime">
                                        <label for="spId">SPID：</label>
                                        <input type="text" class="" id="spId" name="spId"
                                               value="<%= null!=spId ?spId:""%>">
                                    </div>
                                    <%--<div class="new-group date form_datetime">
                                        <label for="spName">SP 名称：</label>
                                        <input type="text" class="" id="spName" name="spName"
                                               value="<%= StringUtils.isNotBlank(spName) ?spName:""%>">
                                    </div>--%>
                                    <%--<div class="new-group date form_datetime">
                                        <label for="service">渠道：</label>
                                        <input type="text" class="" id="service" name="service"
                                               value="<%= StringUtils.isNotBlank(service) ?service:""%>">
                                    </div>--%>
                                    <div class="new-group">
                                        <label for="channel">支付方式：</label>
                                        <select id="channel" name="channel">
                                            <option value="0">所有</option>
                                            <%
                                                List<ChannelType> channelTypes = (List<ChannelType>) request.getAttribute("channelTypes");
                                                for (ChannelType channelType : channelTypes) {
                                                    String value = channelType.getName();
                                            %>
                                            <option value="<%=channelType.getId()%>"
                                                    <% if (null != channel && channel.equals(channelType.getId().intValue())) {%>
                                                    selected="selected"<%}%>>
                                                <%=value%>
                                            </option>
                                            <%}%>
                                        </select>
                                    </div>
                                    <div class="button-group">
                                        <button type=" submit" class="btn btn-primary btn-sm borderNone"
                                                id="btnSearch" >查询</button>
                                        <a href="" id="btnDownload" download="sp费率报表.xls" target="_blank">
                                            <button type="button" class="btn btn-primary btn-sm borderNone" >导出</button>
                                        </a>
                                    </div>
                                </form>
                            </div>
                            </br>
                            <div class="tableContent">
                                <table class="table table-bped table-hover">
                                    <thead>
                                    <tr>
                                        <th width="4%">SP ID</th>
                                        <th width="5%">渠道</th>
                                        <th width="5%">SP 账号</th>
                                        <th width="5%">SP 名称</th>
                                        <th width="5%">支付方式</th>
                                        <th width="4%">支付笔数</th>
                                        <th width="4%">总金额
                                        </th>
                                        <th width="4%">SP 费率</th>
                                        <th width="4%">SP 手续费
                                        </th>
                                        <th width="4%">划账金额
                                        </th>
                                        <%--<th width="6%">银行卡号</th>--%>
                                    </tr>
                                    <tr>
                                        <th width="4%"></th>
                                        <th width="5%"></th>
                                        <th width="5%"></th>
                                        <th width="5%"></th>
                                        <th width="5%"></th>
                                        <th width="4%"></th>
                                        <th width="4%"><span style="color: green;"><%=SiteHelper.formatMoney(amount, 100.0)%></span>
                                        </th>
                                        <th width="4%"></th>
                                        <th width="4%"><span style="color: green;"><%=SiteHelper.formatMoney(spFee, 100.0)%></span>
                                        </th>
                                        <th width="4%"><span style="color: green;"><%=SiteHelper.formatMoney(left, 100.0)%></span>
                                        </th>
                                        <%--<th width="6%"></th>--%>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <%
                                        List<List<String>> list = (List<List<String>>) request.getAttribute("lst");
                                        if (CollectionUtils.isNotEmpty(list)) {
                                            for (List<String> p : list) {
                                    %>
                                    <tr>
                                        <td><%=p.get(0)%>
                                        </td>
                                        <td><%=p.get(1)%>
                                        </td>
                                        <td><%=p.get(2)%>
                                        </td>
                                        <td><%=p.get(3)%>
                                        </td>
                                        <td><%=p.get(4)%>
                                        </td>
                                        <td><%=p.get(5)%>
                                        </td>
                                        <td><%=p.get(6)%>
                                        </td>
                                        <td><%=p.get(7)%>
                                        </td>
                                        <td><%=p.get(8)%>
                                        </td>
                                        <td><%=p.get(9)%>
                                        </td>
                                        <%--<td><%=p.get(10)%>
                                        </td>--%>
                                        <%
                                            }
                                        %>
                                    </tr>
                                    <%
                                    } else {
                                    %>
                                    <tr>
                                        <td colspan="10">未找到数据</td>
                                    </tr>
                                    <% }%>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
            </div>
        </section>
    </div>

    <%--<jsp:include page="foot.jsp"></jsp:include>--%>
</div>
<script src="<%= request.getAttribute("StaticHost") %>/js/jquery.dataTables.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/bootstrap-datepicker.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/bootstrap-datepicker.zh-CN.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/adminlte.min.js"></script>

<script>
    $(function () {
        $('#from, #to').datepicker({
            format: "yyyy-mm-dd",
            todayBtn: true,
            clearBtn: true,
            language: "zh-CN"
        });

        initDownload();
    });
    $("#searchForm input, #searchForm select").change(initDownload);
    function initDownload() {
        $("#btnDownload").attr("href", "/statement/sp/export?" + $("#searchForm").serialize());
        $("#btnDownload").attr("download", "SP费率报表 " + $("#from").val() + "至" + $("#to").val() + ".xls");
    }
</script>
</body>
</html>

